<template>
  <div>

    <div style="text-align: center;margin-top: 50px;line-height: 50px;height:200px;background: #fff">
      <div>
        购买成功
      </div>
      <div>{{sec}}秒后跳转到首页。。。</div>
      <el-button type="primary" @click="toOrder">点击查看订单</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: "success",
  data(){
    return{
      sec:5,
      timer:null
    }
  },
  mounted() {
    // this.checkTime();
    // this.checkF5()
  },
  methods:{
    checkF5(){
      document.oncontextmenu = function(){
        return false;
      }
      document.onkeydown = function (e) {
        var evt = window.event || e;
        var code = evt.keyCode || evt.which;
        if (code == 116) {
          if (evt.preventDefault) {
            evt.preventDefault();
          } else {
            evt.keyCode = 0;
            evt.returnValue = false
          }
        }
      }
    },
    checkTime(){
      this.timer = window.setInterval(()=>{
        this.sec --;
        if (this.sec == 0){
          window.clearInterval(this.timer);
          this.$router.push('/home');
        }
      },1000);
    },
    toOrder(){
      window.clearInterval(this.timer);
      this.$router.push('/order-info')
    }
  }
}
</script>

<style>
 .footer{
    display: none !important;
  }
</style>
